﻿Public Partial Class Formulario_web16
    Inherits System.Web.UI.Page

    Dim ocnProfesor As New CapaNegocio.Profesores()


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cargargrilla()
    End Sub

    Function cargargrilla()
        Dim ds As New DataSet

        ds = ocnProfesor.obtenerProfesor()

        Me.GridViewProfesor.DataSource = ds.Tables(0)

        Me.GridViewProfesor.DataBind()
        Return Me.GridViewProfesor
    End Function

    Protected Sub ButtonGuardar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonGuardar.Click
        Try
            ocnProfesor.InsertarProfesor(Me.TextBoxDniProfesor.Text, Me.TextBoxNombre.Text _
                                        , CDate(Me.CalendarFechaNac.Text), Me.TextBoxEmail.Text _
                                        , Me.TextBoxDomicilio.Text, Me.TextBoxEstadoCivil.Text)
            cargargrilla()
        Catch ex As Exception
            Session.Add("exError", ex)
            Response.Redirect("ManejarError.aspx")
        End Try
    End Sub
End Class